<% content_for :title do %>Bestellingen<% end %>
<% if @orders.size > 0 %>

 <% @orders.each do |order| %>
<h2>Bestelling op <%=format_date order.created_at %></h2>
<h3>Gegevens</h3>
<dl>
  <dt>Status: </dt>
  <dd><%=get_status(order.status)%></dd>
</dl>

<h3>Adres</h3>
<dl>
  <dt>Voornaam:</dt>
  <dd><%=h order.contact_first_name %></dd>
  <dt>Achternaam:</dt>
  <dd><%=h order.contact_surname %></dd>
  <dt>E-mailadres:</dt>
  <dd><%=h order.contact_email %></dd>

  <% if order.address_company.size > 0 %>
  <dt>Bedrijf:</dt>
  <dd><%=h order.contact_surname %></dd>
  <% end %>

  <dt>Stad: </dt>
  <dd><%=h order.address_city %></dd>
  <dt>Straat: </dt>
  <dd><%=h order.address_street %></dd>
  <dt>Huisnummer: </dt>
  <dd><%=h order.address_house_number %> <%=order.address_house_number_addition %></dd>
  <dt>Postcode: </dt>
  <dd><%=h order.address_postal_code %></dd>
  <dt>Telefoonnummer:</dt>
  <dd><%=h order.address_telephone_number %></dd>

  <% if order.address_fax_number.size > 0 %>
  <dt>Faxnummer:</dt>
  <dd><%=h order.address_fax_number %></dd>
  <% end %>


  <% if order.address_mobile_number.size > 0 %>
  <dt>Mobiele telefoon:</dt>
  <dd><%=h order.address_mobile_number %></dd>
  <% end %>
</dl>


<h3>Producten</h3>
<table width="100%">
  <tr>
    <th width="55%">Naam</th>
    <th width="15%">Hoeveelheid</th>
    <th width="10%">Verstuurd</th>
    <th width="10%">Prijs</th>
    <th width="10%">Totaal</th>
    <th>&nbsp;</th>
  </tr>

<% order.order_items.each do |item|  %>
  <tr>
    <td><%=item.product ? item.product.name : '?' %></td>
    <td align="center"><%=item.quantity %></td>
    <td align="center"><%=item.shipped_quantity %></td>
    <td align="center"><%=item.quantity %>&nbsp;x&nbsp;<%=format_price item.original_price %>&nbsp;=</td>
    <td align="center"><%=format_price item.total_cost %></td>
  </tr>
 <%  end %>

  <tr>
    <td>Verzondkosten</td>
    <td>-</td>
    <td>-</td>
    <td>-</td>
    <td align="center"><%=format_price order.shipping_cost %></td>
  </tr>

  <tr>
    <td colspan="5"><hr></td>
    <td>+</td>
  </tr>

  <tr>
    <td>-</td>
    <td align="center"><%=order.total_products %></td>
    <td>-</td>
    <td>-</td>
    <td align="center"><%=format_price order.total_cost %></td>
  </tr>

</table>

<% end  %>

<% else %>

  <p>Geen bestellingen gevonden.</p>

<% end %>


  <p>
    Pagina's:
    <% (1..@pages).each do |i| %>

      <% unless i == 1 %>|<%  end %>

      <% if i == @page %>
        <strong><%=i %></strong>
      <% else %>
        <%=link_to i, {:page => i } %>
      <% end %>
    <% end %>

  </p>